<template>
  <div>
    <div class="commentItem">
      <div class="top">
        <div class="left">
          <span>{{ obj.user.nickname }}</span> &nbsp;&nbsp;&nbsp;
          <span>{{ obj.user.create_date }}</span>
        </div>
        <span @click="replyFn(obj.id)">回复</span>
      </div>
      <commentItem
        v-if="obj.parent"
        :obj="obj.parent"
        @updateComment="replyFn"
      ></commentItem>
      <div class="bottom">{{ obj.content }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: "commentItem",
  data() {
    return {};
  },
  props: ["obj"],
  created() {
    // console.log(this.obj);
  },
  methods: {
    replyFn(id) {
      this.$emit("updateComment", id);
    },
  },
};
</script>

<style lang="less" scoped>
.commentItem {
  border: 1px solid #ccc;
  padding: 5px;
  margin-top: 10px;
  .top {
    font-size: 12px;
    color: #aaa;
    display: flex;
    justify-content: space-between;
  }
  .bottom {
    font-size: 13px;
    line-height: 40px;
  }
}
</style>